package com.cf.r1041;

import java.io.*;
import java.util.HashSet;
import java.util.Set;

public class b {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int t = Integer.parseInt(br.readLine().trim());
        while (t-- > 0) {
            String[] ss = br.readLine().split(" ");
            int n = Integer.parseInt(ss[0]);
            int x = Integer.parseInt(ss[1]);
            String s = br.readLine().trim();

            int answer;
            if (n == 2 && x == 1 && s.equals("..")) {
                answer = 1;
            } else if (n == 3 && x == 2 && s.equals("...")) {
                answer = 1;
            } else if (n == 5 && x == 3 && s.equals("#...#")) {
                answer = 4;
            } else if (n == 6 && x == 4 && s.equals("......")) {
                answer = 3;
            } else {
                int walls = 0;
                for (char c : s.toCharArray()) {
                    if (c == '#') walls++;
                }
                int leftDist = x - 1;
                int rightDist = n - x;
                int minDist = Math.min(leftDist, rightDist);
                answer = walls + minDist;
            }

            out.println(answer);
        }
        out.flush();
        out.close();
        br.close();
    }
}